package com.shujia.hive;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class HiveTest {
    public static void main(String[] args)throws Exception {
        //加载包
        Class.forName ("org.apache.hive.jdbc.HiveDriver");
        //链接
        Connection connection = DriverManager.getConnection ("jdbc:hive2://master:10000/shujia");
        //执行器
        String sql="select*from students";
        PreparedStatement ps = connection.prepareStatement (sql);
        //处理数据
        ResultSet rs = ps.executeQuery ( );
        while(rs.next ()){
            System.out.println (rs.getString ("name") );
        }
        rs.close ();
        ps.close ();
        connection.close ();
    }
}
